import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';

class ErrorHandlerService {
  static final ErrorHandlerService _instance = ErrorHandlerService._internal();
  factory ErrorHandlerService() => _instance;
  ErrorHandlerService._internal();

  void handleError(BuildContext? context, String message, {bool showSnackBar = true}) {
    // 使用EasyLoading显示错误
    EasyLoading.showError(message);

    // 如果提供了context且需要显示SnackBar，则显示SnackBar
    if (context != null && showSnackBar) {
      EasyLoading.showError(message);
    }
  }

  void showSuccess(String message) {
    EasyLoading.showSuccess(message);
  }

  void showInfo(String message) {
    EasyLoading.showInfo(message);
  }
}